package com.company.ThreadsCommunication;

/**
 * 作者：13687
 * 日期：2017/6/5
 * 项目：ThreadPoolsDemo
 * 描述：减少线程
 */
public class DecreaseThread extends Thread {
	public DecreaseThread(NumberLockHolder numberHolder) {
		this.numberHolder = numberHolder;
	}

	//	private NumberHolder numberHolder;
	private NumberLockHolder numberHolder;

/*	public DecreaseThread(NumberHolder numberHolder) {
		this.numberHolder = numberHolder;
	}*/

	@Override
	public void run() {
		for (int i = 0; i < 20; ++i) {
			// 进行一定的延时
			try {
				Thread.sleep((long) Math.random() * 1000);
			}
			catch (InterruptedException e)
			{
				e.printStackTrace();
			}

			// 进行减少操作
			numberHolder.decrease();
		}
	}

}